<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <input type="button" value="点击我" onclick="DayOfYear(2000,2,8)" />
    <script>
        function DayOfYear(year,month,day){
            var days=0;
            var months = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
            for( var i=0;i<month-1;i++)
            {
                days += months[i];
            }
            days += day;
            if(month==months[1] && IsLeapYear(year))
            {
                days = days + 1;
            }
            document.write("第"+days+"天");
        }
        function IsLeapYear(year) {
            var flag = false;
            if ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) )
                flag = true;
        }
    </script>
</body>
</html>